<template>
	<view>
		<!-- 轮播图 -->
		<view class="wrap">
			<u-swiper :list="list" border-radius='0' height="750" mode="dot"></u-swiper>
		</view>
		<view class="content">
			<view class="contentBox">
				<view class="boxMoeny">￥{{detailStr.price}}</view>
				<view class="boxTitle">{{detailStr.name}}</view>

				<view class="boxText">{{detailStr.descr}}</view>
			</view>
		</view>
		<wanl-divider width="40%">设备详情</wanl-divider>
		<view class="wanl-goods-content bg-white" id="details">
			<u-parse :html="detailStr.content"></u-parse>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
				detailStr: {}
			}
		},
		onLoad(e) {
			console.log(e)
			this.worksDetail(e.id)
		},
		methods: {
			// 设备详情
			async worksDetail(id) {
				await uni.request({
					url: '/wisdom/device_product/detail',
					method: 'post',
					data: {
						id: id

					},
					success: res => {
						console.log('worksDetail', res)
						if (res.data.images) {
							const arr = res.data.images.split(',')
							const newArr = arr.map(itm => {
								return this.$wanlshop.oss(itm)
							})
							console.log(newArr)
							res.data.images = newArr
						}
						//详情正则
						res.data.content = res.data.content.replace(/<img [^>]*src=['"]([^'"]+)[^>]*>/gi, (
							match,
							capture) => {
							var img =
								`<img style="display: block; max-width: 100%;" src="${this.$wanlshop.oss(capture, 500, 0)}">`;
							return img;
						});
						this.list = res.data.images
						this.detailStr = res.data

					}
				});
			},
		}
	}
</script>

<style lang="scss">
	.content {
		padding: 0 30rpx;
		padding-top: 1rpx;
		background: #fff;

		.contentBox {
			width: 100%;
			height: auto;
			padding-bottom: 16rpx;

			.boxTitle {
				font-size: 34rpx;
				font-family: PingFang SC-Bold, PingFang SC;
				font-weight: bold;
				color: #333333;
				margin-top: 10rpx;
			}

			.boxMoeny {
				font-size: 36rpx;
				font-family: DIN-Bold, DIN;
				font-weight: bold;
				color: #E31F1F;
				margin-top: 18rpx;
			}

			.boxText {
				font-size: 26rpx;
				font-family: PingFang SC-Medium, PingFang SC;
				font-weight: 500;
				color: #888888;
				line-height: 30rpx;
				margin-top: 8rpx;
			}
		}

		// 评论
		.comment {
			width: 100%;
			height: auto;
			margin-top: 48rpx;
			border-top: 1rpx solid #e1e1e1;

			.commentText {
				font-size: 26rpx;
				font-family: PingFang SC-Medium, PingFang SC;
				font-weight: 500;
				color: #555555;
				line-height: 30rpx;
				margin-top: 14rpx;
			}

			.commentFlex {
				display: flex;
				width: 100%;
				align-items: center;
				margin-top: 26rpx;
				padding-bottom: 48rpx;

				.commentFlexImg {
					width: 68rpx;
					height: 68rpx;
					border-radius: 100%;
				}

				.commentFlexInt {
					width: 604rpx;
					height: 64rpx;
					background: #F6F6F6;
					border-radius: 32rpx;
					margin-left: auto;
					padding: 0 28rpx;

					.int {
						font-size: 26rpx;
						font-family: PingFang SC-Medium, PingFang SC;
						font-weight: 500;
						color: #AAAAAA;
						line-height: 64rpx;
					}
				}
			}
		}
	}
</style>